import React, { Component } from 'react'
import PropTypes from 'prop-types'

const Item = (props) => {
    const { title, done } = props.detail;
    const deleteItem = () => {
        const { id } = props.detail;
        props.deleteItem(id);
    }
    const changeStatus = () => {
        const { id } = props.detail;
        props.changeStatus(id);
    }
    return (
        <li><input type='checkbox' onChange={changeStatus} checked={done} /> {title}<button onClick={deleteItem}>删除</button></li>
    )
}

Item.prototype = {
    detail: PropTypes.object.isRequired,
    deleteItem: PropTypes.func.isRequired,
    changeStatus: PropTypes.func.isRequired
}

export default Item



